//
//  OosUserDao.m
//  oos4ios
//
//  Created by Pablo Gonzalez on 4/12/11.
//  Copyright 2011 11870.com. All rights reserved.
//

#import <oos4ios/DAOs/OosUserDao.h>
#import "../../Atom/Queries/OosUserQuery.h"
#import "../../Atom/Entries/OosUserEntry.h"
#import "../../Atom/Feeds/OosUserFeed.h"
#import "../../Parsers/OosUserEntryParser.h"
#import "../../Parsers/OosUserFeedParser.h"
#import "OosDao+Internal.h"

@implementation OosUserDao

+ (OosUserDao *) daoFromSlug: (NSString *) slug 
{
    return [[[OosUserDao alloc] initFromSlug: slug] autorelease];
}
- (OosUserDao *) initFromSlug: (NSString *) slug
{
    self = [super init];
    if (self) {
        self->mSlug = [slug retain];
    }
    return self;
}

+ (OosUserDao *) daoFromMe
{
    return [[[OosUserDao alloc] initFromMe] autorelease];
}
- (OosUserDao *) initFromMe
{
    self = [super init];
    return self;
}

- (OosQuery *) query
{
	OosQuery *query = nil;
    if (mSlug) {
        query = [OosUserQuery queryFromUserSlug: mSlug];
    } else {
        query = [OosUserQuery queryFromMe];
    }
	[query packStore: self.options];
	return query;
}

- (void)initAtomService:(OosAtomService *)atomService
{
    atomService.entryClass = [OosUserEntry class];
    atomService.feedClass = [OosUserFeed class];
}

- (id<IOosFeedParser>) feedParser
{
    if (!mSlug) {
        return [OosUserFeedParser instance];
    }
    return nil;
}

- (id<IOosEntryParser>) entryParser
{
    if (mSlug) {
        return [OosUserEntryParser instance];
    }
    return nil;
}

- (void)dealloc
{
    [mSlug release];
    [super dealloc];
}

@end
